from typing import List


class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        ans, carry = [], 1
        for i in range(len(digits) - 1, -1, -1):
            sum = digits[i] + carry
            if sum >= 10:
                carry = 1
                ans.insert(0, sum % 10)
            else:
                carry = 0
                ans.insert(0, sum)
        if carry == 1:
            ans.insert(0, 1)
        return ans